﻿using System;
using System.Net;
using System.Windows.Media;
using System.Windows.Media.Imaging;
namespace InteractiveMapApp
{
    class TimeSlot
    {
        #region declare variables

        int timeSlotID;
        public int TimeSlotID
        {
            get { return timeSlotID; }
            set { timeSlotID = value; }
        }

        bool showFilter = true;
        public bool ShowFilter
        {
            get { return showFilter; }
            set { showFilter = value; }
        }

        ImageSource timeSlotImageSourceSelected;
        public ImageSource TimeSlotImageSourceSelected
        {
            get { return timeSlotImageSourceSelected; }
            set { timeSlotImageSourceSelected = value; }
        }

        ImageSource timeSlotImgUnSelected;
        public ImageSource TimeSlotImgUnSelected
        {
            get { return timeSlotImgUnSelected; }
            set { timeSlotImgUnSelected = value; }
        }

        ImageSource read_timeslotImg;
        public ImageSource Read_timeslotImg
        {
            get { return read_timeslotImg; }
            set { read_timeslotImg = value; }
        }

        public string selectedImgURL;
        public string SelectedImgURL
        {
            get { return selectedImgURL; }
            set { selectedImgURL = value; }
        }

        public string unselectedImgURL;
        public string UnselectedImgURL
        {
            get { return unselectedImgURL; }
            set { unselectedImgURL = value; }
        }

        public string read_timeslotURL;
        public string Read_timeslotURL
        {
            get { return read_timeslotURL; }
            set { read_timeslotURL = value; }
        }
        #endregion

        /// <summary>
        /// creates timeslot
        /// </summary>
        /// <param name="timeSlID">the id of the timeslot</param>
        /// <param name="normalImgURL">Image that represents the timeslot</param>
        public TimeSlot(int timeSlID, string normalImgURL, string unselectImgURL, string read_URL)
        {
            this.timeSlotID = timeSlID;
            this.ShowFilter = true;
            this.selectedImgURL = normalImgURL;
            this.unselectedImgURL = unselectImgURL;
            this.read_timeslotURL = read_URL;

            //selected image
            try
            {
                WebClient wcNormalImg = new WebClient();
                System.IO.Stream streamNormalImg = wcNormalImg.OpenRead(MainWindow.iconsStarterPath + normalImgURL);
                System.Drawing.Bitmap tsImgNrml = new System.Drawing.Bitmap(streamNormalImg);
                this.timeSlotImageSourceSelected = Utility.GetImage(tsImgNrml);
            }
            catch
            {
                this.timeSlotImageSourceSelected = new BitmapImage(new Uri("/InteractiveMapApp;component/Images/timelinething.png", UriKind.Relative));
            }

            //unselected image
            try
            {
                WebClient wc = new WebClient();
                System.IO.Stream stream = wc.OpenRead(MainWindow.iconsStarterPath + unselectImgURL);
                System.Drawing.Bitmap ts = new System.Drawing.Bitmap(stream);
                this.timeSlotImgUnSelected = Utility.GetImage(ts);
            }
            catch
            {
                this.timeSlotImgUnSelected = new BitmapImage(new Uri("/InteractiveMapApp;component/Images/timelinething.png", UriKind.Relative));
            }

            //timeslot read_image
            try
            {
                WebClient wc = new WebClient();
                System.IO.Stream stream = wc.OpenRead(MainWindow.iconsStarterPath + read_URL);
                System.Drawing.Bitmap ts = new System.Drawing.Bitmap(stream);
                this.read_timeslotImg = Utility.GetImage(ts);
            }
            catch
            {
                this.read_timeslotImg = new BitmapImage(new Uri("/InteractiveMapApp;component/Images/timelinething.png", UriKind.Relative));
            }
        }

        public object Clone()
        {
            return this.MemberwiseClone();
        }
    }
}
